def generate_pulse_signal(amplitude, pulse_width, period, num_samples, filename):
    signal = [amplitude if (i % period) < pulse_width else 0 for i in range(num_samples)]
    with open(filename, 'w') as f:
        for value in signal:
            f.write(f"{value}\n")
    return signal