Made SWAP define
Removed the complicated double buffer
Reuse some variable
removed extra filename pointer, using argc instead